package com.wc.alorithm_luogu._二分.P1024_一元三次方程求解;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/3/17 10:06
 * @description https://www.luogu.com.cn/problem/P1024
 * 零点定理， a < b, f(a) * f(b) < 0, 说明a,b之间一定存在 0 点
 */
public class Main {
    static double a, b, c, d;

    // 根于根的差的绝对值>=1,说明在1，的区间内是可能存在根的
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        a = sc.nextDouble();
        b = sc.nextDouble();
        c = sc.nextDouble();
        d = sc.nextDouble();
        for (int i = -100, j = 0; i < 100 && j < 3; i++) {
            double l = i;
            double r = i + 1;
            double y1 = f(l);
            double y2 = f(r);
            if (y1 == 0.00) {
                System.out.printf("%.2f ", i * 1.0);
                j++;
            } else {
                if (y1 * y2 < 0) {
                    while (r - l > 0.001) {
                        double mid = (l + r) / 2;
                        if (f(mid) * f(r) < 0) l = mid;
                        else r = mid;
                    }
                    System.out.printf("%.2f ", l);
                    j++;
                }
            }
        }
    }

    static double f(double x) {
        return a * x * x * x + b * x * x + c * x + d;
    }
}
